# encoding: utf-8
import os
from tools.log import log

class ResourcePath():
    """
    资源路径类
    """
    def __init__(self):
        self.__pwd = os.path.dirname(__file__)
        
        # 路径依赖
        self._model_zoo = "model_zoo"
        self._checkpoint_model = "checkpoint_model"
        self._keras_h5_model = "keras_h5_model"
        self._pytorch_model = "pytorch_model"
        self._tflite_model = "tflite_model"
        self._tfpb_model = "tfpb_model"
        
        
        self._test_images = "test_images"
        self._font = "font"
    
    def getResPath(self):
        log.info(self.__pwd)
        return self.__pwd
    
    def getFontPath(self):
        """
        :return: 中文字库路径
        """
        temp_path = os.path.join(self.__pwd, self._font, "simsun.ttc")
        assert os.path.exists(temp_path)
        log.info(temp_path)
        return temp_path
    
    def getRoadLandmarkDectetModelByTflitePath(self):
        """
        :return: 车道线中心点预测模型，tflite格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tflite_model, 'car_db_detection.tflite')
        assert os.path.exists(temp_path)
        return temp_path
    
    def getRoadFollowDetectModelByTflitePath(self):
        """
        :return: 车道线中心点预测模型，tflite格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tflite_model, 'road_model.tflite')
        assert os.path.exists(temp_path)
        return temp_path
    
    def getLandmarkDetectModelByTflitePath(self):
        """
        :return: 沙盘标志物目标检测模型 tflite格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tflite_model, 'landmark_detection.tflite')
        assert os.path.exists(temp_path)
        return temp_path

    def getTrafficSignDetection(self):
        """
        :return: 交通标志物目标检测模型 tflite格式
        """
        temp_path = os.path.join(self.__pwd,
                                 self._model_zoo,
                                 self._tflite_model,
                                 'car_all_jtbs.tflite')
        assert os.path.exists(temp_path)
        return temp_path

    
    def getTextRecModelPath(self):
        """
        :return:  汉字识别模型， 检测点文件
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, 'hanzi_model')
        
        return temp_path
    
    def getLandmarkClassificaModelPath(self):
        """
            :return:  标志物识别分类模型， 检测点文件
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, 'bzw_model')
    
        return temp_path
    
    
    def getTrafficSignsRecModelByCheckPointPath(self):
        """
        :return:  TFT交通标识识别模型  tf 检查点格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, "jtbz_model")
        return temp_path
    
    
    def getLandmarkClassificaModelByCheckPointPath(self):
        """
        :return: 标志物分类模型  tf 检查点格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, 'bzw_model')
        assert os.path.exists(temp_path)
        return temp_path
    
    def getLandmarkDetectModelByTfPb(self):
        """
        :return: 标志物目标检测模型 tf Pb格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tfpb_model, 'landmark_detect.pb')
        assert os.path.exists(temp_path)
        return temp_path
    
    
    def getRoadFollowingModelByTensorrtPath(self):
        """
        :return: 车道线中心点预测模型， tensorrt格式
        """
        temp_path = os.path.join(self.__pwd,
                                 self._model_zoo,
                                 self._pytorch_model,
                                 'road_following_model_trt.pth')
        assert os.path.exists(temp_path)
        return temp_path
    
    def getRoadFollowingModelByPytorchPath(self):
        """
        :return: 车道线中心点预测模型， pytorch格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._pytorch_model, "road_following_model_trt.pth")
        assert os.path.exists(temp_path)
        return temp_path
    
    def getTrafficSignsDetectByTflitePath(self):
        """
        :return: 交通标识目标检测 TFT、静态标志物， tflite格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tflite_model, "jtbz_detect.tflite")
        assert os.path.exists(temp_path)
        return temp_path
    
    def getTrafficSignsDetectByTfH5Path(self):
        """
        :return: 交通标识目标检测 TFT、静态标志物， tf keras h5格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._keras_h5_model, "jtbz_detect.h5")
        assert os.path.exists(temp_path)
        return temp_path
    
    def getTrafficSignsDetectLabelPath(self):
        """
        :return: 交通标识目标检测 标签
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._keras_h5_model, "jtbz_detect_label.txt")
        assert os.path.exists(temp_path)
        return temp_path
    
    def getRoadLandmarkDetectModelByTfliteLabelPath(self):
        """
        :return: 道路地标目标检测 标签
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tflite_model, "car_db_detection_label_tflite.txt")
        assert os.path.exists(temp_path)
        return temp_path

    def getLandmarkDetectModelByTfliteLabelPath(self):
        """
        :return: 标志物检测模型 标签
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tflite_model, 'landmark_detect_label_tflite.txt')
        assert temp_path
        return temp_path
    
    def getLandmarkDetectModelByTfPbLabelPath(self):
        """
        :return: 标志物检测模型 标签 对应pb模型
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._tfpb_model, 'landmark_detect_pb.txt')
        assert temp_path
        return temp_path

    def getTextRecLablePath(self):
        """
        :return: 汉字识别模型标签， txt格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, 'hanzi_label.txt')
        assert os.path.exists(temp_path)
        return temp_path

    def getLandmarkClassificaLablePath(self):
        """
        :return: 标志物分类模型标签  txt格式
        """
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, 'bzw_class_label.txt')
        assert os.path.exists(temp_path)
        return temp_path
    
    def getTrafficSignsRecLablePath(self):
        temp_path = os.path.join(self.__pwd, self._model_zoo, self._checkpoint_model, 'jtbz_label.txt')
        assert os.path.exists(temp_path)
        return temp_path

    def getTrafficSignDetectionLabelPath(self):
        temp_path = os.path.join(self.__pwd,
                                 self._model_zoo,
                                 self._tflite_model,
                                 'car_all_jtbs_label.txt')
        assert os.path.exists(temp_path)
        return temp_path

    def getTestImg_HanZi(self):
        return os.path.join(self.__pwd, self._test_images, "hanzi.jpg")

    def getTestImg_BZW(self):
        timp_path = os.path.join(self.__pwd, self._test_images, "landmark.jpg")
        log.info(timp_path.split('\\'))
        timp_path = r"/".join(timp_path.split('\\'))
        log.info(timp_path)
        return timp_path

    def getTestImg_JTBS(self):
        return os.path.join(self.__pwd, self._test_images, "jtbs.jpg")

    def getTestImg_PLATE(self):
        return os.path.join(self.__pwd, self._test_images, "plate.jpg")

    def getTfrecordTrain(self):
        return os.path.join(self.__pwd, 'tfrecord', 'train.tfrecord')

    def getTestRoadFollow(self):
        return os.path.join(self.__pwd, self._test_images, 'road.jpg')

    def getTestRoadFollow_1(self):
        return os.path.join(self.__pwd, self._test_images, 'road_1.jpg')

    def getTestQRCode(self):
        return os.path.join(self.__pwd, self._test_images, 'qrcode.jpg')

    def getTestTrafficYellow(self):
        return os.path.join(self.__pwd, self._test_images, 'traffic_yellow.jpg')

    def getTestTrafficGrea(self):
        return os.path.join(self.__pwd, self._test_images, 'traffic_grea.jpg')

    def getTestTrafficRed(self):
        return os.path.join(self.__pwd, self._test_images, 'traffic_red.jpg')

resourcePath = ResourcePath()

if __name__ == '__main__':
    res = resourcePath
    print(res.getResPath())
    print(res.getFontPath())
